import random
class Hero:
    def __init__(self,name,health,power):
        self.name=name
        self.health=health
        self.power=power
    def attack(self,other_hero):
        damage=random.randint(1,self.power)
        other_hero.health-=damage
        print(f"{self.name}对{other_hero.name}造成了{damage}点伤害！")
        if other_hero.health<=0:
            print(f"{other_hero.name}被击败了！")
        else:
            print(f"{other_hero.name}还剩{other_hero.health}点血")
superman=Hero("超人",200,50)
batman=Hero("蝙蝠侠",110,80)
print("战斗开始！")
while superman.health>0 and batman.health>0:
    if random.choice([True,False]):
        superman.attack(batman)
    else:
        batman.attack(superman)
